<?php

namespace App\Remote\AMap\Track;

use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpFoundation\Request as RequestAlias;

/**
 * 服务管理
 */
class ServiceRemote extends Remote
{
    /**
     * @param string $name
     * @param string $desc
     * @return mixed
     * @throws GuzzleException
     * @throws ValidationException
     */
    public static function add(string $name, string $desc)
    {
        return self::customRequestV3(
            "/v1/track/service/add?" . http_build_query(self::withCommonHttpQueryParams()),
            RequestAlias::METHOD_POST,
            [
                "name" => $name,
                "desc" => $desc
            ],
            [
                'Content-Type' => 'application/x-www-form-urlencoded'
            ]
        );
    }

    /**
     * 服务列表
     *
     * @return mixed
     * @throws GuzzleException
     * @throws ValidationException
     */
    public static function list()
    {
        return self::customRequestV3(
            "/v1/track/service/list?" . http_build_query(self::withCommonHttpQueryParams()),
            RequestAlias::METHOD_GET,
        );
    }
}
